package com.maduar.batch.quartz;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.quartz.CronScheduleBuilder;
import org.quartz.CronTrigger;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.JobKey;
import org.quartz.JobListener;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerMetaData;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.SimpleTrigger;
import org.quartz.TriggerBuilder;
import org.quartz.TriggerKey;
import org.quartz.impl.StdSchedulerFactory;
import org.springframework.context.annotation.PropertySource;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;

/**
 * Description:
 *
 * @Author maduar maduar@163.com
 * @Date 2021-07-11 22:58
 */
@Slf4j
@PropertySource(value = {"classpath:quartz.properties"})
public class JobMainTest {

    public static void main(String[] args) throws SchedulerException, InterruptedException {
        // 1. 调度器
        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();

        // 2. 任务实例(jobDetail) myJob任务的唯一标识

        List<JobListener> jobListeners = scheduler.getListenerManager().getJobListeners();

        log.info("getTriggerGroupNames: {}", JSON.toJSONString(scheduler.getTriggerGroupNames()));

        scheduler.shutdown();
    }
}
